﻿namespace OverStore.Configuration.Storage
{
    using OverStore.Runtime.OverStoreContext;
    using OverStore.Runtime.Storage;

    /// <summary>
    /// Base class for factory of <see cref="ICommand"/> implementation inherited from <see cref="AdoNetCommandBase"/> class.
    /// </summary>
    public abstract class AdoNetCommandBaseConfiguration : IComponentConfiguration<ICommand>
    {
        /// <summary>
        /// When overriden in derived classes, creates new instance of class inherited from <see cref="AdoNetCommandBase"/>.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>New instance of <see cref="AdoNetCommandBase"/> class.</returns>
        public abstract AdoNetCommandBase CreateCommand(IOverStoreContext context);

        /// <summary>
        /// Creates the data storage command using specified configuration.
        /// </summary>
        /// <param name="context">The context provides services may be required for <see cref="ICommand"/> instance.</param>
        /// <returns>
        /// The <see cref="ICommand"/> instance with specified configuration.
        /// </returns>
        ICommand IComponentConfiguration<ICommand>.CreateComponent(IOverStoreContext context)
        {
            return CreateCommand(context);
        }
    }
}
